package no.sachmuld.methodcombination.examples.reflection.strategy.v1;

import no.sachmuld.methodcombination.api.BehaviourChain;
import no.sachmuld.methodcombination.api.reflection.Default;

/**
 *
 */
public abstract class Duck {

    private BehaviourChain<FlyBehaviour> flyBehaviourChain = new BehaviourChain<>();
    private BehaviourChain<QuackBehaviour> quackBehaviourChain = new BehaviourChain<>();

    final public void fly() {
        new Default<Void>().build(FlyBehaviour.class, Duck.class, "fly").execute(this, flyBehaviourChain);
    }

    final public void quack() {
        new Default<Void>().build(QuackBehaviour.class, Duck.class, "quack").execute(this, quackBehaviourChain);
    }

    public Duck with(FlyBehaviour... behaviours) {
        flyBehaviourChain.addAll(behaviours);
        return this;
    }

    public Duck with(QuackBehaviour... behaviours) {
        quackBehaviourChain.addAll(behaviours);
        return this;
    }

}
